﻿using ProtoBuf;
using MongoDB;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;

namespace ToyChat.BuiltinModules
{
    /// <summary>
    /// This class is used to store user permissions for a specific channel in the database
    /// </summary>
    [ProtoContract(Name = "UserPermissions")]
    public class UserPermissions
    {
        /// <summary>
        /// Gets or Sets the Database ID of this object
        /// </summary>
        [BsonId]
        public ObjectId ID { get; set; }

        /// <summary>
        /// Gets or Sets the ID of the user this object provides permissions for
        /// </summary>
        [ProtoMember(1)]
        public string Username { get; set; }

        /// <summary>
        /// Gets or Sets the ID of the channel these permissions apply to
        /// </summary>
        [ProtoMember(2)]
        public int ChannelID { get; set; }

        /// <summary>
        /// Gets or Sets the actual permissions
        /// </summary>
        [ProtoMember(3)]
        public ChannelPermissionFlags Permissions { get; set; }

        /// <summary>
        /// Gets or Sets the ID of the request that was made to get this <see cref="UserPermissions"/> object
        /// </summary>
        [BsonIgnore]
        [ProtoMember(4)]
        public int RequestID { get; set; }
    }
}